package svmc.stp.hoaitt;

import java.util.ArrayList;

public class Library {
	static final int MAX = 10000;
	ArrayList<Book> books = new ArrayList<Book>();

	public Library(ArrayList<Book> books) {
		super();
		this.books = books;
	}
	
	public void hintBook() {
		ArrayList<Book> listHintBook = new ArrayList<Book>();
		for (Book bk : books) {
			if (bk.getState() == 0) {
				listHintBook.add(bk);
			}
		}
	}
	
	public void borrowBook(Book b) {
		if (b.getState() == 1) {
			System.out.println("You can borrow this book.");
			b.setState(0);
		} else {
			System.out.println("It is not available.");
		}
	}

	
	public void returnBook(Book rtBook) {
		if (books.contains(rtBook)) {
			rtBook.setState(1);
		} else {
			System.out.println("Sorry! It's not mine");
		}
		
	}
	
	public void printBookAvailable() {
		for (int i = 0; i < books.size(); i++) {
			if ((books.get(i).state) == 1) {
				System.out.println(books.get(i));
			}
		}
	}
	
	public void printBookDoBorrow() {
		for (int i = 0; i < books.size(); i++) {
			if ((books.get(i).state) == 0) {
				System.out.println(books.get(i));
			}
		}
	}
}
